package com.bz.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import com.bz.common.Codeenum;
import com.bz.common.ResponseDto;
import com.bz.common.ResponseUtils;

@Component
public class AuthAccessDeniedHandler implements AccessDeniedHandler {
    // @Value("${server.servlet.context-path}")
    // private String name;

    @Override
    public void handle(HttpServletRequest httpServletRequest,
                       HttpServletResponse httpServletResponse,
                       AccessDeniedException e) throws IOException, ServletException {
        ResponseUtils.setResponse(httpServletResponse, new ResponseDto<>(Codeenum.NOT_LOGIN));
    }
}
